package cj.web.point.dao;
/*
 *  
 *  
*/
import java.util.List;
import net.paoding.rose.jade.annotation.DAO;
import net.paoding.rose.jade.annotation.SQL;
import net.paoding.rose.jade.annotation.SQLParam;
import cj.web.point.domain.PointConfig;

/**
 * 
 * @author 
 *
 */
@DAO
public interface PointConfigDAO{
	
	@SQL("SELECT * FROM PointConfig WHERE deleteFlag=1 #if(:t.categoryId != null){ AND categoryId LIKE '%##(:t.categoryId)%' } #if(:t.name != null){ AND name LIKE '%##(:t.name)%' } ORDER BY updateAt DESC LIMIT :t.start,:t.length ")
    List<PointConfig> query(@SQLParam("t") PointConfig pointConfig);
	
	@SQL("SELECT count(1) FROM PointConfig WHERE deleteFlag=1 #if(:t.categoryId != null){ AND categoryId LIKE '%##(:t.categoryId)%' } #if(:t.name != null){ AND name LIKE '%##(:t.name)%' } ")
    int querySize(@SQLParam("t") PointConfig pointConfig);
    
    @SQL("SELECT * FROM PointConfig WHERE id=:1")
    PointConfig queryById(int id);
    
    @SQL("INSERT INTO PointConfig (code,name,categoryId,pointNum,deleteFlag,createUser,createAt,updateUser,updateAt) VALUES (:t.code,:t.name,:t.categoryId,:t.pointNum,1,:t.createUser,now(),:t.updateUser,now())")
    void create(@SQLParam("t") PointConfig pointConfig);
	
	@SQL("UPDATE PointConfig SET code=:t.code,name=:t.name,categoryId=:t.categoryId,pointNum=:t.pointNum,updateUser=:t.updateUser,updateAT=now() WHERE id=:t.id")
    void update(@SQLParam("t") PointConfig pointConfig);
    
    @SQL("UPDATE PointConfig SET deleteFlag=0 WHERE id=:1")
    void deleteById(int id);
}